#include "MApplication.h"
#include <QIcon>


MApplication::MApplication(int &argc, char *argv[], bool unitTesting)
#ifdef __MOBILE__
    : QGuiApplication       (argc, argv)
#else
    : QApplication          (argc, argv)
#endif
    , _runningUnitTests     (unitTesting)
#ifdef QT_DEBUG

#endif
{

}


void MApplication::_initCommon(void)
{
    _initEngine();
    //_initViewer();
}



void  MApplication::_initEngine()
{
    pEngine = new MEngine();
    QObject::connect(pEngine, SIGNAL(quit()), this, SLOT(quit()));
}

void  MApplication::_initViewer()
{
    viewer = new QQuickView();
    QObject::connect(viewer->engine(), SIGNAL(quit()), this, SLOT(quit()));
}


int  MApplication::_loadQMLFile()
{
    //pEngine->addImportPath(":/imports");
    pEngine->addImportPath("qrc:///");
    pEngine->load(QStringLiteral("qrc:/main.qml"));
    if (pEngine->rootObjects().isEmpty())
        return _ERROR_FILE;
    return 0;
}

int  MApplication::_loadQMLFile(bool sta)
{
    Q_UNUSED(sta);
    viewer->engine()->addImportPath(":/imports");
    viewer->engine()->addImportPath("qrc:///");
    viewer->setFlags(Qt::FramelessWindowHint| Qt::Window );
    viewer->setSource(QStringLiteral("qrc:/main.qml"));
    viewer->show();
    return 0;
}
